#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QSystemTrayIcon>
#include <QMessageBox>
#include <QNetworkReply>
#include <QTextCodec>
#include <QTimer>
#include <QCloseEvent>
#include <QDesktopWidget>
#include <QMenu>
#include <QLabel>
#include <QNetworkProxy>
#include <QSettings>

class ConfigHelper;
class StockInfo;
class ConfigDialog;
class StocksContainer;

namespace Ui
{
    class MainWindowClass;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void startNetWork();
    void centerOnScreen ();
    void refreshWindow();
    ConfigHelper* getConf() {return confHelper_;}

    bool isProxyChanged;
    bool isStocksChanged;

protected:
    void closeEvent(QCloseEvent *event);


private slots:
    void slotDownFinished(QNetworkReply * qnr);
    void slotStartNetWork();
    void slotIconActivated(QSystemTrayIcon::ActivationReason reason);
    void slotConfigWindow();

private:
    void createSystemTrayIcon();
    void uiInit();
    void networkInit();
    void refreshTableContent();

    Ui::MainWindowClass *ui;
    QSystemTrayIcon *trayIcon_;
    QNetworkAccessManager *nwaMgr_;
    QTimer *timer_;
    QMenu *trayIconMenu_;

    QAction *settingAction;
    QAction *restoreAction;
    QAction *minimizeAction;
    QAction *quitAction;

    StocksContainer *container_;

    ConfigHelper *confHelper_;

};



#endif // MAINWINDOW_H

